﻿Imports System.IO
Imports System.Runtime.InteropServices
Imports IWshRuntimeLibrary
Imports Microsoft.Web.WebView2.Core

Public Class 资源分享
    Private Async Sub 资源分享_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Width = 主窗体.TableLayoutPanel1.ColumnStyles(1).Width
        Await WebView21.EnsureCoreWebView2Async()
        Dim web As String = "https://26ak921oh814.vicp.fun" '这里需替换成自己的网址
        ' 添加新窗口请求事件处理 
        AddHandler WebView21.CoreWebView2.NewWindowRequested, AddressOf NewWindowRequestedHandler
        WebView21.CoreWebView2.Navigate(web)
    End Sub

    Private Sub NewWindowRequestedHandler(sender As Object, e As CoreWebView2NewWindowRequestedEventArgs)
        ' 取消新窗口打开 
        e.Handled = True
        ' 导航到目标URL 
        WebView21.CoreWebView2.Navigate(e.Uri)
    End Sub


End Class